#ifndef _SYM_PERF_H_
#define _SYM_PERF_H_

#if 0
#define ASYN_RESOURCE_RECOVERY
#endif
/* ASYN_MODE_BENCHMARK:
 * Measure the sym&hash benchmark speed number under
 * async mode. If disable this macro, the enqueue part and callback function of dequeue work separately(async mode).
 */
#if 0
#define ASYN_MODE_BENCHMARK
#endif

#ifndef ASYN_RESOURCE_RECOVERY
#define N_THREADS	32 
#define DO_NUM		32	
#else
#define N_THREADS	64 
#define DO_NUM		2	
#endif

extern u8 malg,mtype,mopt;
extern int mdatasize,mivsize,mkeysize;
extern char mstr[];

extern u8 malg2,mtype2,mopt2;
extern int mdatasize2,mivsize2,mkeysize2;

int sm1_cbc_encrypt_newapi(u8 *in,u8 *out,int inlen,u8 *key,u8 *iv);
int sm1_cbc_decrypt_newapi(u8 *in,u8 *out,int inlen,u8 *key,u8 *iv);
int sm3_hmac_newapi(u8 *key,int keylen,u8 *input,int inlen,u8 *output);

int snoop_sp_sm4sm3_enc(void);
int snoop_sp_sm4sm3_dec(void);
int snoop_sp_sm4sm3_enc_asyn(void);
int snoop_sp_sm4sm3_dec_asyn(void);

int snoop_sp_sm1sm3_enc(void);
int snoop_sp_sm1sm3_dec(void);
int snoop_sp_sm1sm3_enc_asyn(void);
int snoop_sp_sm1sm3_dec_asyn(void);

int sm1_cbc_encrypt_newapi_asyn_recovery(u8 *in,u8 *out,int inlen,u8 *key,u8 *iv);
int sm4_ecb_encrypt_newapi_asyn_recovery_key_in_ram(u8 *in,u8 *out,int inlen,dma_addr_t key_addr,u8 *iv);


int sm1_cbc_decrypt_newapi_asyn_recovery(u8 *in,u8 *out,int inlen,u8 *key,u8 *iv);
int sm3_hmac_newapi_asyn_recovery(u8 *key,int keylen,u8 *input,int inlen,u8 *output);

int sym_newapi_speed_do(void *_mparm);
int hash_newapi_speed_do(void *_mparm);
int sym_newapi_speed_do_asyn_recovery(void *_mparm);
int hash_newapi_speed_do_asyn_recovery(void *_mparm);

int snoop_newapi_speed_do(void *_mparm);
int snoop_sp_newapi_speed_do(void *_mparm);
int snoop_newapi_speed_do_asyn(void *_mparm);
int snoop_sp_newapi_speed_do_asyn(void *_mparm);

struct ccore_cards_t *get_ccore_cards(void);

void inline_cnstr_jobdesc_cipher_core(uint32_t *desc,struct cipher_core *cipher);
int inline_cnstr_jobdesc_cipher_sg_core(struct csec_priv_t *csec_priv,uint32_t *desc,struct cipher_core *cipher);
int inline_cnstr_jobdesc_cipher_sg_pre(struct csec_priv_t *csec_priv,uint32_t *desc,struct cipher_core *cipher,void **sg_virt,dma_addr_t *sg_phy);
void inline_cnstr_jobdesc_hash_core(uint32_t *desc,struct cipher_core *cipher);
void inline_cnstr_jobdesc_snoop_core(uint32_t *desc,struct cipher_core *ciphercore);
void inline_cnstr_jobdesc_snoop_sp(uint32_t *desc,struct cipher_core *ciphercore);

int cards_enqueue(struct csec_priv_t *csec_priv,uint32_t *desc_addr,dma_addr_t desc_phy_addr,
void (*callback)(struct csec_priv_t *csec_priv,uint32_t *desc_addr,dma_addr_t desc_phy_addr,uint32_t status, void *arg),void *arg);

struct csec_priv_t * cards_enqueue_pre(struct ccore_cards_t *ccore_cards);
int memcmp_with0(unsigned char *input,int len);
void mytime_init(void);
struct timespec mytime_on(void);
void mytime_off(struct timespec tv);

extern const char snoop_sm4sm3enc_sm4_ctrl_data[];
extern const char snoop_sm4sm3enc_sm3_ctrl_data[];
extern const char snoop_sm4sm3dec_sm4_ctrl_data[];
extern const char snoop_sm3dec_ctrl_data[];
extern const char snoop_sm1sm3enc_sm1_ctrl_data[];
extern const char snoop_sm1sm3enc_sm3_ctrl_data[];
extern const char snoop_sm1sm3dec_sm1_ctrl_data[];

extern struct timespec mytime;
extern struct list_head algtv_head_list;
extern spinlock_t algtv_list_lock;
struct custom_result {
	struct completion op_done;
	volatile int rst;
	void *sg_virt;
	dma_addr_t sg_phy;
};

struct alg_time {
	char alg_type[32];
	uint32_t run_times;
	uint64_t tv;
	struct list_head list;
};



#endif
